import React from 'react';
import { hasPermission } from './permission';

interface IActionCode {
	actionCode?: string
}
export const withPermission = (WrappedComponent: React.ComponentType) => class extends React.Component<IActionCode> {
	render() {
		const { actionCode } = this.props;
		let isShow = !actionCode || hasPermission(actionCode)
		return (isShow && <WrappedComponent {...this.props} />)
	}
}